package com.itheima.array2;

public class ArrayDemo1 {
    public static void main(String[] args) {
        int[][] arr={
                {11,22,33},
                {44,55,66}
        };
        printArray(arr);
        int sum=getSum(arr);
        System.out.println("该数组和为"+sum);


    }

    //遍历二维数组
    public static void printArray(int[][] arr){
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr[i].length; j++) {
                System.out.println(arr[i][j]);
            }
        }
    }

    //遍历二维数组求和
    public static int getSum(int arr[][]){
        int sum=0;
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr[i].length; j++) {
                sum+=arr[i][j];
            }
        }
        return sum;
    }
}
